package com.woniuxy.bookmallmanagersrever.mapper;

import com.woniuxy.bookmallmanagersrever.entity.TUrlPermission;
import com.woniuxy.bookmallmanagersrever.vo.PermissionVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface TUrlPermissionMapper extends Mapper<TUrlPermission> {
    List<PermissionVo> selectAllMenus();

    List<TUrlPermission> selectPermissionByName(String name);

    @Select("select * from t_url_permission where parent_id = -1")
    List<TUrlPermission> selectAllParentPermission();

    @Delete("delete from t_url_permission where parent_id = #{id}")
    void deletePermissionByParentId(int id);

    @Delete("delete from t_role_url_permission where url_permission_id = #{id}")
    void deleteRoleAndPermissionByPermissionId(int id);

    @Select("select id from t_url_permission where parent_id = #{id}")
    List<Integer> selectPerIdByParentId(int id);

    void deleteAllChildPermissionInRole(List<Integer> lists);

    List<PermissionVo> selectMenusByManager(String username);
}